package com.zxdemo.service.imp;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.zxdemo.jpa.model.Role;
import com.zxdemo.mybatis.dao.RoleMapper;
import com.zxdemo.service.RoleService;

@Service("roleService")
public class RoleServiceImpl implements RoleService{
			@Autowired
			private RoleMapper roleMapper;

			@Override
			public Role queryObject(Long roleId) {
				return roleMapper.queryObject(roleId);
			}

			@Override
			public List<Role> queryList(Integer offset, Integer limit) {
				return roleMapper.queryList(offset, limit);
			}

			@Override
			public int queryTotal() {
				return roleMapper.queryTotal();
			}

			@Override
			@Transactional
			public void save(Role role) {
				role.setCreateTime(new Date());
				roleMapper.save(role);
				//保存角色与菜单关系
				
			}

			@Override
			public void update(Role role) {
				roleMapper.update(role);
				//更新角色与菜单关系
			}

			@Override
			public void delete(Long roleId) {
				roleMapper.delete(roleId);
			}

			@Override
			public void deleteBatch(List<Long> roleIdList) {
				roleMapper.deleteBatch(roleIdList);
			}
			
}
